var spPop = function() {
    this.width = document.body.clientWidth * 0.6;
    this.height = document.body.clientHeight * 0.6;
    this.innerHTML = "Welcome use super pop window. Designed by dzlua (505544956@qq.com).";
    this.opacity = 0.5;
    this.maskbackground = "#000";
    this.background = "white";
    this.zIndex = 1000;
    this.borderRadius = "10";
    //----------------------//
    this.frame = null;
    this.mask = null;
    this.box = null;
    this.dialog = null;
};

spPop.prototype.Show = function () {
    var mask = document.createElement("div");
    mask.style.width = "100%";
    mask.style.height = "100%";
    mask.style.position = "fixed";
    mask.style.top = "0";
    mask.style.left = "0";
    mask.style.opacity = this.opacity;
    mask.style.filter = "alpha(opacity=" + (this.opacity * 100) + ")";
    mask.style.background = this.maskbackground;

    var box = document.createElement("div");
    box.style.width = this.width;
    box.style.height = this.height;
    box.style.position = "absolute";
    box.style.top = "50%";
    box.style.left = "50%";
    box.style.marginLeft = "-" + (this.width/2) + "px";
    box.style.marginTop = "-" + (this.height/2) + "px";
    box.style.background = this.background;
    box.style.borderRadius = this.borderRadius + "px";

    var dialog = document.createElement("div");
    dialog.innerHTML = this.innerHTML;
    dialog.style.width = this.width - this.borderRadius * 2;
    dialog.style.height = this.height - this.borderRadius * 2;
    dialog.style.margin = this.borderRadius;
    dialog.style.overflow = "auto";

    var frame = document.createElement("div");
    frame.style.width = "100%";
    frame.style.height = "100%";
    frame.style.position = "fixed";
    frame.style.top = "0";
    frame.style.zIndex = this.zIndex;

    box.appendChild(dialog);
    frame.appendChild(mask);
    frame.appendChild(box);
    document.body.appendChild(frame);

    this.frame = frame;
    this.mask = mask;
    this.box = box;
    this.dialog = dialog;
};

spPop.prototype.Close = function () {
    if (!this.frame) return;
    this.frame.parentElement.removeChild(this.frame);
};
